/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "leader_plan")
@NamedQueries({
    @NamedQuery(name = "LeaderPlan.findAll", query = "SELECT l FROM LeaderPlan l"),
    @NamedQuery(name = "LeaderPlan.findByLpId", query = "SELECT l FROM LeaderPlan l WHERE l.lpId = :lpId"),
    @NamedQuery(name = "LeaderPlan.findByLpDescrip", query = "SELECT l FROM LeaderPlan l WHERE l.lpDescrip = :lpDescrip"),
    @NamedQuery(name = "LeaderPlan.findByLpCreate", query = "SELECT l FROM LeaderPlan l WHERE l.lpCreate = :lpCreate"),
    @NamedQuery(name = "LeaderPlan.findByLpBegin", query = "SELECT l FROM LeaderPlan l WHERE l.lpBegin = :lpBegin"),
    @NamedQuery(name = "LeaderPlan.findByLpName", query = "SELECT l FROM LeaderPlan l WHERE l.lpName = :lpName"),
    @NamedQuery(name = "LeaderPlan.findByLpProperty", query = "SELECT l FROM LeaderPlan l WHERE l.lpProperty = :lpProperty"),
    @NamedQuery(name = "LeaderPlan.findByLpEnd", query = "SELECT l FROM LeaderPlan l WHERE l.lpEnd = :lpEnd")})
public class LeaderPlan implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "lp_id")
    private Integer lpId;
    @Column(name = "lp_descrip")
    private String lpDescrip;
    @Basic(optional = false)
    @Column(name = "lp_create")
    @Temporal(TemporalType.DATE)
    private Date lpCreate;
    @Column(name = "lp_begin")
    @Temporal(TemporalType.DATE)
    private Date lpBegin;
    @Basic(optional = false)
    @Column(name = "lp_name")
    private String lpName;
    @Basic(optional = false)
    @Column(name = "lp_property")
    private int lpProperty;
    @Column(name = "lp_end")
    @Temporal(TemporalType.DATE)
    private Date lpEnd;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leaderPlan", fetch = FetchType.LAZY)
    private List<Task> taskList;
    @JoinColumn(name = "mp_id", referencedColumnName = "mp_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ManagerPlan managerPlan;
    @JoinColumn(name = "leader_id", referencedColumnName = "user_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;

    public LeaderPlan() {
    }

    public LeaderPlan(Integer lpId) {
        this.lpId = lpId;
    }

    public LeaderPlan(Integer lpId, Date lpCreate, String lpName, int lpProperty) {
        this.lpId = lpId;
        this.lpCreate = lpCreate;
        this.lpName = lpName;
        this.lpProperty = lpProperty;
    }

    public Integer getLpId() {
        return lpId;
    }

    public void setLpId(Integer lpId) {
        this.lpId = lpId;
    }

    public String getLpDescrip() {
        return lpDescrip;
    }

    public void setLpDescrip(String lpDescrip) {
        this.lpDescrip = lpDescrip;
    }

    public Date getLpCreate() {
        return lpCreate;
    }

    public void setLpCreate(Date lpCreate) {
        this.lpCreate = lpCreate;
    }

    public Date getLpBegin() {
        return lpBegin;
    }

    public void setLpBegin(Date lpBegin) {
        this.lpBegin = lpBegin;
    }

    public String getLpName() {
        return lpName;
    }

    public void setLpName(String lpName) {
        this.lpName = lpName;
    }

    public int getLpProperty() {
        return lpProperty;
    }

    public void setLpProperty(int lpProperty) {
        this.lpProperty = lpProperty;
    }

    public Date getLpEnd() {
        return lpEnd;
    }

    public void setLpEnd(Date lpEnd) {
        this.lpEnd = lpEnd;
    }

    public List<Task> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<Task> taskList) {
        this.taskList = taskList;
    }

    public ManagerPlan getManagerPlan() {
        return managerPlan;
    }

    public void setManagerPlan(ManagerPlan managerPlan) {
        this.managerPlan = managerPlan;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (lpId != null ? lpId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LeaderPlan)) {
            return false;
        }
        LeaderPlan other = (LeaderPlan) object;
        if ((this.lpId == null && other.lpId != null) || (this.lpId != null && !this.lpId.equals(other.lpId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.LeaderPlan[lpId=" + lpId + "]";
    }

}
